package org.infosys;

import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
* @Description: 订单启动类
* @Author: hank
* @Version: 1.0
* @Date:  2022/7/28 2:40
*/
@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
public class OrderServerApplication {

    //配置一个RestTemplate ，Spring封装的一个基于Restful风格的http客户端 工具
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


    public static void main( String[] args ) {
        SpringApplication.run(OrderServerApplication.class, args);
    }

    //负载均衡算法
    //全局随机负载均衡算法
    @Bean
    public RandomRule randomRule() {
        return new RandomRule();
    }
    /*
     @Bean
    public AvailabilityFilteringRule availabilityFilteringRule(){
        return new AvailabilityFilteringRule();
    }
     */
}
